package com.myproject.thread.join;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Test4 {

    public static void main(String[] args) throws InterruptedException {

        //join时间大于线程执行时间
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdf.format(new Date())+" :start");
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(500000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                SimpleDateFormat sdff = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

                System.out.println(sdff.format(new Date())+" :over");
            }
        });
        t.start();
        t.join(2000000);
        System.out.println(sdf.format(new Date())+" :over");


    }
}
